#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<assert.h>
#include<string.h>

void* my_memcpy(void *ch1, const void *ch2, int size)
{
	int i = 0;
	for(i=0;i<size;i++)
	{
		((char*)ch1)[i] = ((char*)ch2)[i];
	}
}

void* my_memmove(void* ch1, const void* ch2, unsigned int size)
{
	assert(ch1 && ch2);
	if ((char*)ch1 - (char*)ch2 > size || ch1<ch2)
	{
		int i = 0;
		for (i = 0; i < size; i++)
		{
			((char*)ch1)[i] = ((char*)ch2)[i];
		}
	}
	else if (((char*)ch1)-((char*)ch2)<size)
	{
		int i = size;
		while (!(i<0))
		{
			((char*)ch1)[i] = ((char*)ch2)[i];
			i--;
		}
	}
}
int main()
{
	char ch1[50] = "abcdefghijk";
	char ch2[50] = "abcdefghijk";
	my_memcpy(ch1+2, ch1, 5);
	my_memmove(ch2 + 2, ch2, 5);
	printf("my_memcpy= %s\n",ch1);
	printf("my_memmove=%s", ch2);

	return 0;
}
